package com.zzti.contril;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.zzti.Dao.LoginDao;
import com.zzti.impl.LoginDaoimpl;

/**
 * Servlet implementation class LoginqServlet
 */
public class LoginServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
   
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String username=request.getParameter("name");
		String password=request.getParameter("password");
		LoginDao ld=new LoginDaoimpl(); 
		System.out.print(password);
		if(ld.selectAll(username)) {
			response.sendRedirect("EmployeeServlet");
			//request.getRequestDispatcher("showEmployee.jsp").forward(request, response);
		}else {
			HttpSession session =request.getSession();
			session.setAttribute("result", "1");
			request.getRequestDispatcher("Login1.jsp").forward(request, response);
		}
		}

	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}